home *** CD-ROM | disk | FTP | other *** search
- PROGRAM BENCH_MARK;
- { This program was converted from BASIC into Pascal.
-
- FLOATING-POINT BENCHMARK
-
- The following is a program to test the accuracy of floating
- point functions (from Sept. DR DOBBS):
- 10 A=1
- 20 FOR I%=1 TO 2499
- 30 A=TAN(ATN(EXP(LOG(SQR(A*A))))) + 1
- 40 NEXT
- 50 PRINT A
- 60 STOP
-
- The correct printout is A=2500 exactly.
-
- IBM-PC BASIC 1.0 fails miserably, giving A=2179.8 (only 1 sig-
- nificant figure of accuracy!). In contrast, an APPLE II or
- Commodore 64 gives 2500 to at least 7 figures. Using the 8087
- with a polyFORTH version of the benchmark, I obtained 2500 to
- 13 figures in 5.0 seconds. (NOTE: See March,84 D. DOBBS for
- the results aginst many systems.)
- }
-
-
- VAR
- a : REAL;
- i : INTEGER;
-
- BEGIN
- writeln(' This program was converted from BASIC into Pascal. ');
- writeln(' ');
- writeln(' FLOATING-POINT BENCHMARK ');
- writeln(' ');
- writeln(' The following is a program to test the accuracy of floating ');
- writeln(' point functions (from Sept. DR DOBBS): ');
- writeln(' 10 A=1 ');
- writeln(' 20 FOR I%=1 TO 2499 ');
- writeln(' 30 A=TAN(ATN(EXP(LOG(SQR(A*A))))) + 1 ');
- writeln(' 40 NEXT ');
- writeln(' 50 PRINT A ');
- writeln(' 60 STOP ');
- writeln(' ');
- writeln(' The correct printout is A=2500 exactly. ');
- writeln(' ');
- writeln(' IBM-PC BASIC 1.0 fails miserably, giving A=2179.8 (only 1 sig- ');
- writeln(' nificant figure of accuracy!). In contrast, an APPLE II or ');
- writeln(' Commodore 64 gives 2500 to at least 7 figures. Using the 8087 ');
- writeln(' with a polyFORTH version of the benchmark, I obtained 2500 to ');
- writeln(' 13 figures in 5.0 seconds. (NOTE: See March,84 D. DOBBS for ');
- writeln(' the results aginst many systems.) ');
- a:=1;
- FOR i:= 1 TO 2499 DO
- BEGIN
- a:= ARCTAN( EXP( LN(SQRT(a * a)) ) );
- a:= (SIN(a) / COS(a)) + 1;
- END;
- WRITELN(a:3:11);
- END.